All Questions
355 questions
4votes
4answers
488views
Finding Special Parts in a Word
Task description: Imagine you have a long word made up of small letters like "a", "b", "c", ancd so on. Let’s call this word a puzzle word. We want to look at all the ...
6votes
3answers
515views
locale-aware trim functions for std::string
I have written the below two trim functions for std::string and std::basic_string that are locale-aware. Both trim all white ...
3votes
1answer
177views
Snail matrix in Java - version III (generalizing)
Once again, in the previous version, Alexander Ivanchenko helped me with his awesome answer. Now, I have improved the toString() and, also, generalized the class ...
2votes
3answers
697views
Step-by-step re-arranging of a string with randomized characters
A sloppy code featuring algorithms to efficiently randomize the characters of a string "Hello C" and then print out in the console the re-arrangement process for every character. ...
4votes
2answers
485views
Z-Function/ Algorithms on strings. C++
The problem: Given a string s. For each i from 1 to |s|, find the number of occurrences of its prefix of length i in the string. Input: The first line of input contains an integer q (1≤q≤10⁵) — the ...
4votes
2answers
596views
O(nlogn) Lexicographically minimal rotation code but tle on this particular case
Based on a small suggestion here , this code tries to find lexicographically minimal rotation (question) by successively comparing two adjacent substrings in the very left , that can potentially give ...
-2votes
1answer
192views
Design an algorithm to predict words based on a skeleton from a given dictionary
The model I'm building first selects a secret word at random from a list. The model which uses an API then returns a row of underscores (space separated)—one for each letter in the secret word—and ...
2votes
3answers
140views
Print last lines of file
Task Write a Ruby function, which accepts a path to a text file and returns a string consisting of the last n lines in reversed order, separated by commas. Example input file: ...
5votes
1answer
148views
Remove smiles from string in-place
I have a coding task. Remove smiles from string in-place. Smile is a set of characters starting from ':' and ending with one or more brackets ')' or one or more brackets '(' Example ...
1vote
3answers
234views
Convert camelCase function name to snake_case
I have the following code: ...
2votes
1answer
83views
Optimising function to strip honorifics from names
Problem I have a list of around ~1000 honorifics, see below for a sample. Given an input string of a name, for example ...
3votes
3answers
617views
Finding first unique character in string
Below is a solution I came up with (in C++) for an algorithm that is supposed to find the first character in a string that only appears once in the input string (the input string is guaranteed to be ...
2votes
1answer
221views
Finding anagram groups using hashing and mapping the alphabet to random numbers
I was solving Group Anagram problem in leetcode. Link for the problem https://leetcode.com/problems/group-anagrams/ Below is the code which I wrote ...
5votes
2answers
1kviews
Count each word within a string
I am looking for a solution with fewer lines of code. This is code that is working perfectly, but I think I typed too much for this algorithm. If I did something wrong, feel free to tell me the error. ...
2votes
1answer
158views
Golang solution to CTCI 1.2: Check whether two strings are permutations of each other
Just started learning Go recently. Did some questions from Cracking the Coding Interview book. Wrote the solutions in Go. Let me know what you think. https://github.com/samjingwen/ctci Below is ...